﻿using Microsoft.EntityFrameworkCore.Migrations;

namespace NFine.Data.Migrations
{
    public partial class Modified_UserLogin_Property : Migration
    {
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropForeignKey(
                name: "FK_sys_user_login_sys_tenant_TenantId",
                table: "sys_user_login");

            migrationBuilder.DropIndex(
                name: "IX_sys_user_login_TenantId",
                table: "sys_user_login");

            migrationBuilder.AlterColumn<long>(
                name: "UserId",
                table: "sys_user_login",
                nullable: true,
                oldClrType: typeof(long));

            migrationBuilder.AddColumn<string>(
                name: "TenantName",
                table: "sys_user_login",
                maxLength: 255,
                nullable: true);
        }

        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropColumn(
                name: "TenantName",
                table: "sys_user_login");

            migrationBuilder.AlterColumn<long>(
                name: "UserId",
                table: "sys_user_login",
                nullable: false,
                oldClrType: typeof(long),
                oldNullable: true);

            migrationBuilder.CreateIndex(
                name: "IX_sys_user_login_TenantId",
                table: "sys_user_login",
                column: "TenantId");

            migrationBuilder.AddForeignKey(
                name: "FK_sys_user_login_sys_tenant_TenantId",
                table: "sys_user_login",
                column: "TenantId",
                principalTable: "sys_tenant",
                principalColumn: "Id",
                onDelete: ReferentialAction.Restrict);
        }
    }
}
